<?php
/**
 * Description of goldenShield
 *
 * @author Baagoe
 */
class GoldenShield {
    
    //Loads game configuration
    public function __construct($config) {
        if(!is_array($config)) {
            return false;
        }
        
        $this->gameFile = $config['mainGameFile'];
        $this->jquery = $config['jquery'];
        $this->jsFolder = $config['jsFolder'];
        $this->jsObject = $config['javaObjects'];
        $this->cssFiles = $config['cssFiles'];
        $this->title = $config['title'];
        $this->icon = $config['icon'];
        return true;
    }
    
    //Loads the game
    public function loadGame() {
        if(!file_exists($this->gameFile)) {
            return false;
        } 
        
        $game = $this;
        require $this->gameFile;
        return true;
    }
    
    //Loads the different javascripts
    private function loadScripts() {
        if(is_array($this->jsObject)) {
            $ret = "";
            foreach ($this->jsObject as $file) {
                $ret .= "<script src='". $this->jsFolder. $file. "' type='text/javascript'></script>\n";
            }
            return $ret;
        }
        
        return false;
    }
    
    //Loads the different CSS files
    private function loadCSS() {
        if(is_array($this->cssFiles)) {
            $ret = "";
            foreach ($this->cssFiles as $file) {
                $ret .= "<link rel='stylesheet' href='". $file. "'/>\n";
            }
            return $ret;
        }
        
        return false;
    }
    
    //Loads jQuery script
    private function loadjQuery() {
        if(!$this->jquery) {
            return false;
        }
        
        return "<script src='". $this->jquery. "' type='text/javascript'></script>";
    }
    
    //Returns title
    private function title() {
        if(!$this->title) {
            return false;
        }
        
        return $this->title;
    }
    
    //Returns icon string
    private function icon() {
        if(!$this->icon) {
            return false;
        }
        
        return '<link rel="icon" type="image/x-icon" href="'. $this->icon. '" />';
    }
    
    
}

?>
